Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add coercion of arguments to @wrap #991

Merged
merged 7 commits into from
May 31, 2024
Merged

Conversation

lgoettgens
Copy link
Member

@lgoettgens lgoettgens commented May 14, 2024

Resolves the first part of oscar-system/Oscar.jl#3720.

Due to the way this is now implemented, it is very easy to adapt it for similar type annotations like GapInt.

Currently also contains #992 to make the testsuite run on nightly. This PR can be rebased once #992 is merged.

Copy link

codecov bot commented May 14, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 75.77%. Comparing base (c53585e) to head (88a9e3b).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #991      +/-   ##
==========================================
+ Coverage   75.75%   75.77%   +0.02%     
==========================================
  Files          51       51              
  Lines        4190     4203      +13     
==========================================
+ Hits         3174     3185      +11     
- Misses       1016     1018       +2     
Files Coverage Δ
src/macros.jl 94.87% <83.33%> (-3.59%) ⬇️

... and 1 file with indirect coverage changes

Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks exactly like what I was hoping for, great :-)

@fingolfin
Copy link
Member

@ThomasBreuer any concerns, comments, questions about this

@ThomasBreuer
Copy link
Member

I have no objections.

If I understand the idea right then we can (should?) use the new feature in Oscar as follows.
For an Oscar group G, we can call Oscar.GAPWrap.ConjugacyClasses(G) instead of Oscar.GAPWrap.ConjugacyClasses(GapObj(G)).
We cannot call Oscar.GAPWrap.Size(G) instead of Oscar.GAPWrap.Size(GapObj(G)) because Size does not get wrapped with the requirement that its argument is a GapObj.
Thus the Oscar code will look a bit funny if we omit the unnecessary GapObj calls for arguments of Oscar.GapWrap.Something functions.

@fingolfin
Copy link
Member

But we could change the wrapper for Size to require a GAPObj. In fact there is a ton of wrappers we could do that. I was simply lazy when setting up most of them.

@ThomasBreuer
Copy link
Member

Looking at the list in Oscar/src/GAP/wrappers.jl, my understanding is that most (all?) of the ::Any arguments can be safely changed to ::GAP.Obj, assuming that there are no methods for the GAP functions in question that take other Julia objects.

This change would not help us to get an automatic indirection from Oscar objects to underlying GAP objects.

Writing ::GapObj instead would probably fit to the way the functions are intended for Oscar, although the GAP functions in question really admit any input --the IsSomething filters are of that kind. We could go this way.

@fingolfin
Copy link
Member

We may be looking at different subsets of the wrappers? Because my view is that the majority would be safe to use GapObj, as no Int, Bool or FFE makes sense as argument for e.g. Size, IsFreeGroup, Image (for the first argument at least, the second is different), and a ton more.

That said, as I already suggested in the feature request leading to this: we could also add code to deal with GAP.Obj and GAP.GapInt. Indeed, we just have to add a few more elseif to the code in this PR to catch those.

src/macros.jl Outdated Show resolved Hide resolved
src/macros.jl Outdated Show resolved Hide resolved
src/macros.jl Outdated Show resolved Hide resolved
Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Perhaps a test could be added?

@ThomasBreuer I agree that the drawback of this code is that things become ever so slightly more "magical" and harder to understand, but I feel it is worth it here. What do you think?

src/macros.jl Outdated Show resolved Hide resolved
src/macros.jl Show resolved Hide resolved
src/macros.jl Show resolved Hide resolved
@lgoettgens
Copy link
Member Author

I added something similar as your suggestions as comments in the different cases.

Perhaps a test could be added?

There already is a doctest coercing a julia string to a GAP string. For tests for GAP.Obj and GAP.GapInt I am afraid that I don't know enough about the types to find suitable GAP functions to test this properly.

Co-authored-by: Max Horn <[email protected]>
@fingolfin fingolfin merged commit 2cf157c into oscar-system:master May 31, 2024
14 checks passed
@lgoettgens lgoettgens deleted the lg/wrap branch June 18, 2024 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants